/**
 *  预警预报应用深化-污染源分析-污染源行业分析
 *  Created by lins on 2018/7/17.
 */
'use strict';
angular.module("MetronicApp").directive('industryBar', function () {
    return {
        scope: {
            id: "@",
            data: "="
        },
        restrict: 'EA',
        template: '',
        replace: true,
        link: function ($scope, element, attrs, controller) {
            function getOption(data) {
                var option = {
                    title : {
                        text: '污染源行业分析',
                        x:'center',
                        textStyle:{  //标题文字设置
                            fontSize: '20',
                            fontWeight: 'bold',
                            color: '#5AB1EF'
                        }
                    },
                    grid: {
                        left: '3%',
                        right: '0%',
                        bottom: '3%',
                        containLabel: true
                    },
                    xAxis:  {
                        type: 'category',
                        data: ['石家庄市','唐山市','秦皇岛市','邯郸市','邢台市','保定市','张家口市','承德市','沧州市','廊坊市','衡水市']
                    },
                    yAxis : [
                        {
                            type : 'value',
                            min: 0,
                            max: 300,
                            interval: 50
                        }
                    ],
                    series : [
                        {
                            type:'bar',
                            barWidth: '10%',
                            data:[80, 280,140,90,175,90,170,70,60,130,160],
                            itemStyle: {
                                normal: {
                                    color: '#8D98B3'
                                }
                            }
                        },
                        {
                            type:'bar',
                            barWidth: '10%',
                            data:[250, 105,70,90,70,155,255,110,290,70,245],
                            itemStyle: {
                                normal: {
                                    color: '#E5CF0D'
                                }
                            }
                        },
                        {
                            type:'bar',
                            barWidth: '10%',
                            data:[180,105,270,160,170,190,65,180,130,175,110],
                            itemStyle: {
                                normal: {
                                    color: '#ACC475'
                                }
                            }
                        },
                        {
                            type:'bar',
                            barWidth: '10%',
                            data:[130,95,210,235,55,80,95,210,265,230,120],
                            itemStyle: {
                                normal: {
                                    color: '#AB8D8B'
                                }
                            }
                        },
                        {
                            type:'bar',
                            barWidth: '10%',
                            data:[160,230,140,95,125,135,180,155,130,100,80],
                            itemStyle: {
                                normal: {
                                    color: '#E388BB'
                                }
                            }
                        },
                        {
                            type:'line',
                            data:[80, 280,140,90,175,90,170,70,60,130,160],
                            itemStyle: {
                                normal: {
                                    color: '#D8807A'
                                }
                            }
                        },
                        {
                            type:'line',
                            data:[250, 105,70,90,70,155,255,110,290,70,245],
                            itemStyle: {
                                normal: {
                                    color: '#5AB1EF'
                                }
                            }
                        },
                        {
                            type:'line',
                            data:[180,105,270,160,170,190,65,180,130,175,110],
                            itemStyle: {
                                normal: {
                                    color: '#FFB980'
                                }
                            }
                        },
                        {
                            type:'line',
                            data:[130,95,210,235,55,80,95,210,265,230,120],
                            itemStyle: {
                                normal: {
                                    color: '#2EC7C9'
                                }
                            }
                        },
                        {
                            type:'line',
                            data:[160,230,140,95,125,135,180,155,130,100,80],
                            itemStyle: {
                                normal: {
                                    color: '#B6A2DE'
                                }
                            }
                        }


                    ]

                };
                return option;
            }

            var myChart = echarts.init(document.getElementById('four'), 'macarons');
            myChart.setOption(getOption($scope.data));

            $scope.$watch('data', function (newVal, oldVal) {
                myChart.setOption(getOption(newVal));
            });
        }
    };
});
